package com.liangfeng.breezebrowser;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.liangfeng.breezebrowser.browsermvp.view.BrowserActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private boolean flag = false;//默认状态栏不隐藏
    private RelativeLayout rl_main;
    private ImageButton ibtn_zoom;
    private View decorView;
    private TextView et_serach;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //clear title
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_main);

        decorView = getWindow().getDecorView();

        ibtn_zoom = (ImageButton) findViewById(R.id.ib_zoom_main);
        rl_main = (RelativeLayout) findViewById(R.id.rl_main);
        et_serach = (TextView) findViewById(R.id.tv_search_main);
        et_serach.setOnClickListener(this);
        ibtn_zoom.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_search_main://jump to webView
                Intent intent = new Intent(this, BrowserActivity.class);
                startActivity(intent);
                break;
            case R.id.ib_zoom_main:
                if (!flag) {//show statu bar
                    decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
                    flag = !flag;
                } else {//hide statu bar
                    // 隐藏状态栏
                    decorView.setSystemUiVisibility(View.INVISIBLE);
                    flag = !flag;
                }
                break;
        }


    }
}
